package com.itheima.myreflect2.Student.demo;

import java.util.HashMap;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @program: Myset
 * @description:
 * @author: xuejingjing
 * @create: 2021-06-20 12:02
 **/
public class MyCurrentTableDemo {
    public static void main(String[] args) throws InterruptedException {

        ConcurrentHashMap<String,String> hm = new ConcurrentHashMap<String,String>();

        //这就是返回的一个类，而不是以前的方法
        Thread thread1 = new Thread(() -> {
            for (int i = 0; i < 25; i++) {
                hm.put(i + "", i + "");
            }
        });

        Thread thread2 = new Thread(() -> {
            for (int i = 25; i < 51; i++) {
                hm.put(i + "", i + "");
            }
        });

        thread1.start();
        thread2.start();

        Thread.sleep(1000);


        for (int i = 0; i < 51; i++) {
            System.out.println(hm.get(i+""));
        }


    }
}
